#include "Test.h"
#include "DebugFactory.h"

namespace AllTing
{

namespace Test
{

Test::Test(const Test& aTest)
{
	strName_ = aTest.strName_;
	bSelected_ = aTest.bSelected_;
	nError_ = aTest.nError_;
	nCurrentTime_ = aTest.nCurrentTime_;
	nElapsedTime_ = aTest.nElapsedTime_;
	bStopOnFailed_ = aTest.bStopOnFailed_;
	func_ = aTest.func_;
	testee_ = aTest.testee_;
}

Test& Test::operator=(const Test& aTest)
{
	strName_ = aTest.strName_;
	bSelected_ = aTest.bSelected_;
	nError_ = aTest.nError_;
	nCurrentTime_ = aTest.nCurrentTime_;
	nElapsedTime_ = aTest.nElapsedTime_;
	bStopOnFailed_ = aTest.bStopOnFailed_;
	func_ = aTest.func_;
	testee_ = aTest.testee_;

	return *this;
}

Test::~Test()
{
}

Bool Test::Run()
{
	if(!SetUp())
		return False;
	
	// Storing active test for reporting.
	DebugFactory::Instance()->ActiveTest(this);

	if(func_)
		nError_ = (func_)();

	if(pTestee_ && testee_)
		nError_ = (pTestee_->*testee_)();		//http://msdn2.microsoft.com/en-us/library/z72c1dfd(vs.80).aspx

	return TearDown();
}

}	// namespace Test

}	// namespace AllTing